layui.define(['table', 'form'], function (exports) {
    var $ = layui.$,
        table = layui.table,
        form = layui.form;

    table.render({
        elem: '#historyVersionTable'
        , url: '/historyVersion/list' //模拟接口
        , cols: [[
            {field: 'id', hide: true, title: 'ID'},
            , {field: 'app_key', width: 288, title: 'app_key'}
            , {field: 'version_f', title: '文件版本', width: 100}
            , {field: 'base_line_md5', title: '基线md5', width: 200}
            , {field: 'config_md5', title: '配置md5', width: 200}
            , {field: 'featrue_md5', title: '特征md5', width: 100}
            , {field: 'fn_ip', title: 'fn的ip', width: 100}
            , {field: 'create_time', title: '创建时间', width: 100}
            , {field: 'version', title: 'version', width: 100}
            , {title: '操作', width: 100, align: 'center', fixed: 'right', toolbar: '#historyBar'}
        ]]
        , page: true
        , limit: 30
        , height: 'full-220'
        , text: {
            none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
        }
    });

    //监听搜索
    form.on('submit(LAY-user-front-search)', function (data) {
        var field = data.field;
        //执行重载
        table.reload('historyVersionTable', {
            where: field
        });
    });

    $.ajax({
        url: '/historyVersion/getApplication',
        method: 'post',
        success: (result) => {
            for (let i = 0; i < result.length; i++) {
                $("#app_key").append("<option value='" + result[i].app_key + "'>" + result[i].app_name + "</option>");//新增
                form.render();
            }
        }
    });

    //对外输出
    exports('historyVersion', {});
});
